package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.CouponCustomerVo;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.StringCodeUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-18  16:03
 * @Description:卡券核销的适配器
 */
public class CardDistHistoryAdapter extends BaseQuickAdapter<CouponCustomerVo, BaseViewHolder> {
    public CardDistHistoryAdapter(int layoutResId, @Nullable List<CouponCustomerVo> data) {
        super(layoutResId, data);
//暂时去掉 因为遮挡条目的点击事件
        addChildClickViewIds(R.id.textviewdistcustomerphone);

    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, CouponCustomerVo complainItemBean) {

        //添加拨打电话的权限：
//        {
//            "beginTime":"2023-08-31 15:12:34",
//                "companyId":11,
//                "couponAmount":20.00,
//                "couponCode":"2023081515212777662991",
//                "couponCustomerId":15,
//                "couponDetail":"餐券1",
//                "couponId":1,
//                "couponImage":"",
//                "couponName":"餐券1",
//                "couponStatus":1,
//                "couponStatusInfo":"",
//                "createCustomerId":108,
//                "createCustomerName":"",
//                "createTime":"2023-08-31 15:12:34",
//                "customerId":63029,
//                "endTime":"2023-08-31 23:59:59",
//                "grantSource":2,
//                "isDelete":0,
//                "managerName":"众诚上汽大众",
//                "passCustomerId":4,
//                "passShopInfoId":1495,
//                "passShopName":"",
//                "passTime":"2023-08-31 15:38:29",
//                "passTrueName":"",
//                "phone":"17531108969",
//                "shopInfoId":1495,
//                "shopName":"",
//                "trueName":"",
//                "updateTime":"2023-08-31 15:38:29",
//                "useStatus":1
//        },

        if (complainItemBean != null) {

            //设置item数据；
            //客户的姓名 以及其他信息
            String customerPersonName = complainItemBean.getTrueName();
            //客户手机号，因为 可能客户名字是空的
            String phoneNumber = complainItemBean.getPhone();
//            卡券的信息 以及其他信息
            String cardInfo = complainItemBean.getCouponName();
//            核销人
            String workerPerson = complainItemBean.getManagerName();
//            核销的时间  2024年2月18日11:39:35需求变动重新修改
            String workerTime = complainItemBean.getManagerTime();
            //发放时间，就是创建时间
            String dispatchTime = complainItemBean.getCreateTime();
//            备注信息
//            String remark = complainItemBean.getRemark();


            //findViews
            //个人的名字
            TextView textviewDistCustomerName = (TextView) baseViewHolder.getView(R.id.textviewdistcustomername);
            //客户的电话
            TextView textViewDistCustomerPhone = (TextView) baseViewHolder.getView(R.id.textviewdistcustomerphone);
            //这个卡券的信息；
            TextView textViewCardDistInfo = (TextView) baseViewHolder.getView(R.id.textviewcarddistinfo);
            //核销人的内容；
            TextView textVieDistWokerPerson = (TextView) baseViewHolder.getView(R.id.textviedistwokerperson);
            //餐券的发放时间
            TextView textViewDispatchTime = (TextView) baseViewHolder.getView(R.id.textviewdispatchtime);
            //核销时间
            TextView textViewDistTime = (TextView) baseViewHolder.getView(R.id.textviewdisttime);
            //核销时间
//            TextView textViewDistRemark = (TextView) baseViewHolder.getView(R.id.textviewdistremark);


            CommUtils.setText(textviewDistCustomerName, customerPersonName);
//          CommUtils.setText(textViewDistCustomerPhone, phoneNumber);//原始手机号
            CommUtils.setText(textViewDistCustomerPhone, StringCodeUtils.mobileEncrypt(phoneNumber));


            CommUtils.setText(textViewCardDistInfo, cardInfo);
            CommUtils.setText(textVieDistWokerPerson, workerPerson);
            CommUtils.setText(textViewDistTime, workerTime);
            CommUtils.setText(textViewDispatchTime, dispatchTime);
//            CommUtils.setText(textViewDistRemark, "remark");

        }
    }
}
